package com.ilove.lottery.frame;

import org.kalmeo.kuix.core.Kuix;
import org.kalmeo.kuix.widget.Screen;
import org.kalmeo.util.frame.Frame;

import com.ilove.core.ILOVE;
import com.ilove.core.ILOVEContants;


public class LotteryMainFrame implements Frame {
	
	public static LotteryMainFrame instance = new LotteryMainFrame();
	private Screen screen;

	public void showScreen() {
		if (screen != null) {
			screen.setCurrent();
		}
	}
	public void onAdded() {
		// Load the screen
		System.out.println("Lottery Mainscreen on Added");
		screen = Kuix.loadScreen(ILOVEContants.LOTTERY_SCREEN, null);
		screen.setCurrent();

	}

	public boolean onMessage(Object identifier, Object[] arguments) {
		if ("ketqua".equals(identifier)) {
			com.vnt.IndexFrame.instance.id = 4;
			com.vnt.IndexFrame.instance.name = "XOSO";
			com.vnt.IndexFrame.instance.code = null;
			Kuix.getFrameHandler().pushFrame(com.vnt.IndexFrame.instance);
		}else if ("cau".equals(identifier)) {
			com.vnt.IndexFrame.instance.id = 4;
			com.vnt.IndexFrame.instance.name = "CAU";
			com.vnt.IndexFrame.instance.code = null;
			Kuix.getFrameHandler().pushFrame(com.vnt.IndexFrame.instance);
		}else if ("soi".equals(identifier)) {
			com.vnt.IndexFrame.instance.id = 4;
			com.vnt.IndexFrame.instance.name = "SOI";
			com.vnt.IndexFrame.instance.code = null;
			Kuix.getFrameHandler().pushFrame(com.vnt.IndexFrame.instance);
		}	
		else if ("back".equals(identifier)) {
			Kuix.getFrameHandler().removeFrame(instance);
			return false;
		} 
		return false;
	}

	public void onRemoved() {
		try {
			com.ilove.frame.MainFrame.instance.showScreen();
			ILOVE.screenMain.cleanUp();
			ILOVE.screenMain = null;
		} catch (Exception e) {
		}	
	}

}
